package orders

import (
	"api/internal/svc"
	"api/internal/types"
	"context"
	"order_srv/orderclient"

	"github.com/zeromicro/go-zero/core/logx"
)

type GetOrderListLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewGetOrderListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetOrderListLogic {
	return &GetOrderListLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *GetOrderListLogic) GetOrderList(req *types.GertOrderListRequest) (resp *types.Response, err error) {
	list, err := l.svcCtx.OrderRpc.GetOrderList(l.ctx, &orderclient.GetOrderListRequest{ //获取订单列表
		PayStatus: int64(req.PayStatus),
	})
	if err != nil {
		return &types.Response{
			Code:    400,
			Message: err.Error(),
		}, nil
	}
	resp = &types.Response{
		Code:    200,
		Message: "success",
		Data:    list,
	}
	return resp, nil
}
